package com.example.service;

import com.example.entity.Resume;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lbq
 * @version 1.0
 * @date 2021/5/30 20:16
 */
@Service
public class ResumeService {

    @Autowired
    private MongoTemplate mongoTemplate;

    public List<Resume> findAll() {
        return mongoTemplate.findAll(Resume.class);
    }

    public List<Resume> queryByCondition() {
        Query query = Query.query(Criteria.where("name").is("测试1"));
        return mongoTemplate.find(query, Resume.class);
    }

    public void insert() {
        mongoTemplate.insert(new Resume().setName("测试1").setSalary(23456.23));
    }

}
